home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-06 | 54.7 KB | 1,643 lines |
- Newsgroups: comp.sources.misc
- From: dan%step.uucp@uunet.uu.net (Daniel Weaver)
- Subject: v25i028: ted - Terminfo/termcap test program, Part03/07
- Message-ID: <1991Nov6.042934.5924@sparky.imd.sterling.com>
- X-Md4-Signature: c510100df33012ac4a57d7ef2f393e9f
- Date: Wed, 6 Nov 1991 04:29:34 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: dan%step.uucp@uunet.uu.net (Daniel Weaver)
- Posting-number: Volume 25, Issue 28
- Archive-name: ted/part03
- Environment: UNIX
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # If this archive is complete, you will see the following message at the end:
- # "End of archive 3 (of 7)."
- # Contents: build.c control.c tparam.c
- # Wrapped by dan@step on Fri Nov 1 11:28:25 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'build.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'build.c'\"
- else
- echo shar: Extracting \"'build.c'\" \(12849 characters\)
- sed "s/^X//" >'build.c' <<'END_OF_FILE'
- X/*
- X** This software is Copyright (c) 1991 by Daniel Weaver.
- X**
- X** Permission is hereby granted to copy, distribute or otherwise
- X** use any part of this package as long as you do not try to make
- X** money from it or pretend that you wrote it. This copyright
- X** notice must be maintained in any copy made.
- X**
- X** Use of this software constitutes acceptance for use in an AS IS
- X** condition. There are NO warranties with regard to this software.
- X** In no event shall the author be liable for any damages whatsoever
- X** arising out of or in connection with the use or performance of this
- X** software. Any use of this software is at the user's own risk.
- X**
- X** If you make modifications to this software that you feel
- X** increases it usefulness for the rest of the community, please
- X** email the changes, enhancements, bug fixes as well as any and
- X** all ideas to me. This software is going to be maintained and
- X** enhanced as deemed necessary by the community.
- X*/
- X#include <stdio.h>
- X
- X/* Create the files needed to fetch the termcap.
- X This program is designed to run under System V. */
- X
- Xextern char *boolfnames[], *boolcodes[], *boolnames[];
- Xextern char *numfnames[], *numcodes[], *numnames[];
- Xextern char *strfnames[], *strcodes[], *strnames[];
- X
- Xstatic int wc, cpl;
- Xstatic FILE *cp, *hp;
- X
- Xstatic char tc_key[] =
- X"kz00kb01cr02bk03ta04bt05kl06kr07ku08kd09kh10EN11PU12PD13ki14kk15LI16LD17kp18ek19ck20pk21mk22nk23ok24";
- X
- X#define CAP_BOOL 1
- X#define CAP_NUM 2
- X#define CAP_STR 3
- X#define CAP_KEY 4
- X
- Xstruct remap_list {
- X int type;
- X char *cap_name, *info_name, *address;
- X};
- X
- Xstruct remap_list tc_remap[] = {
- X CAP_STR, "CF", /* vi */ "civis", "cursor_invisible",
- X CAP_STR, "CO", 0, "cursor_on",
- X CAP_STR, "GS", /* as */ "smacs", "enter_alt_charset_mode",
- X CAP_STR, "GE", /* ae */ "rmacs", "exit_alt_charset_mode",
- X CAP_STR, "ct", 0, "color_terminal",
- X CAP_STR, 0, 0, "clear_all_tabs",
- X 0, 0, 0, 0};
- X
- Xstruct remap_list xenix_remap[] = {
- X CAP_STR, "GS", /* as */ "smacs", "enter_alt_charset_mode",
- X CAP_STR, "GE", /* ae */ "rmacs", "exit_alt_charset_mode",
- X CAP_STR, 0, /* rs1 */ 0, "reset_1string",
- X CAP_STR, 0, /* rs3 */ 0, "reset_3string",
- X CAP_STR, 0, /* is1 */ 0, "init_1string",
- X CAP_STR, 0, /* is3 */ 0, "init_3string",
- X CAP_KEY, "CL", 0, "key_char_left",
- X CAP_KEY, "CW", 0, "key_change_window",
- X CAP_KEY, "EN", 0, "key_send",
- X CAP_KEY, "HM", 0, "key_Home",
- X CAP_KEY, "LD", 0, "key_line_delete",
- X CAP_KEY, "LF", 0, "key_linefeed",
- X CAP_KEY, "NU", 0, "key_next_unlocked_cell",
- X CAP_KEY, "PN", 0, "key_start_print",
- X CAP_KEY, "PD", 0, "key_page_down",
- X CAP_KEY, "PU", 0, "key_page_up",
- X CAP_KEY, "PS", 0, "key_stop_print",
- X CAP_KEY, "RC", 0, "key_recalc",
- X CAP_KEY, "RF", 0, "key_toggle_ref",
- X CAP_KEY, "RT", 0, "key_return",
- X CAP_KEY, "UP", 0, "key_up_arrow",
- X CAP_KEY, "WL", 0, "key_word_left",
- X CAP_KEY, "WR", 0, "key_word_right",
- X#ifdef HUH
- X CAP_STR, "MON", /* SA */ "smam", "enter_am_mode",
- X CAP_STR, "MOF", /* RA */ "rmam", "exit_am_mode",
- X#endif
- X 0, 0, 0, 0};
- X
- X
- Xsend(s)
- Xchar *s;
- X { /* write the data for the .h file */
- X int ls = strlen(s);
- X
- X if (wc) fprintf(hp, ",");
- X ++wc;
- X if (wc + ls > 70) {
- X fprintf(hp, "\n"); wc = 0;
- X }
- X fprintf(hp, " %s", s); wc += ls + 1;
- X }
- X
- X
- Xsend_names(info, cap)
- Xchar *info, *cap;
- X { /* build a string array with the cap and info names */
- X cpl += strlen(info) + strlen(cap) + 5;
- X if (cpl > 70)
- X {
- X fprintf(cp, "\n\t");
- X cpl = strlen(info) + strlen(cap) + 12;
- X }
- X else fprintf(cp, " ");
- X fprintf(cp, "\"%s:%s\",", info, cap);
- X }
- X
- X
- Xremap_keys(def, key)
- Xchar *def;
- Xstruct remap_list key[];
- X { /* expand a termcap personality */
- X int i, j;
- X
- X fprintf(cp, "#ifdef %s\n", def);
- X for (i = j = 0; key[i].type; ++i) {
- X if (key[i].cap_name) {
- X switch (key[i].type) {
- X case CAP_BOOL:
- X fprintf(cp, "\t%s = tgetflag(\"%s\");\n",
- X key[i].address, key[i].cap_name);
- X break;
- X case CAP_NUM:
- X fprintf(cp, "\t%s = tgetnum(\"%s\");\n",
- X key[i].address, key[i].cap_name);
- X break;
- X case CAP_STR:
- X fprintf(cp, "\t%s = tgetstr(\"%s\", &bb);\n",
- X key[i].address, key[i].cap_name);
- X break;
- X case CAP_KEY:
- X fprintf(cp,
- X " enter_key(\"%s\", %s = tgetstr(\"%s\", &bb));\n",
- X key[i].cap_name, key[i].address, key[i].cap_name);
- X break;
- X }
- X if (key[i].info_name) fprintf(cp,
- X "\tcaptrans[cap_index(\"%s\", %d)] = \"%s:%s\";\n",
- X key[i].info_name, strlen(key[i].info_name),
- X key[i].info_name, key[i].cap_name);
- X else {
- X if (j++ == 0) fprintf(hp, "\n#ifdef %s\n", def);
- X switch (key[i].type) {
- X case CAP_BOOL:
- X fprintf(hp, "EXTERN char %s;\n", key[i].address);
- X break;
- X case CAP_NUM:
- X fprintf(hp, "EXTERN int %s;\n", key[i].address);
- X break;
- X case CAP_KEY:
- X case CAP_STR:
- X fprintf(hp, "EXTERN CHARSTAR %s;\n", key[i].address);
- X break;
- X }
- X }
- X }
- X else /* name is missing. Clear the value */
- X switch (key[i].type) {
- X case CAP_BOOL:
- X fprintf(cp, "\t%s = 0;\n", key[i].address);
- X break;
- X case CAP_NUM:
- X fprintf(cp, "\t%s = -1;\n", key[i].address);
- X break;
- X case CAP_KEY:
- X case CAP_STR:
- X fprintf(cp, "\t%s = (char *) 0;\n", key[i].address);
- X break;
- X }
- X }
- X fprintf(cp, "#endif\n");
- X if (j) fprintf(hp, "#endif\n");
- X }
- X
- X
- Xmain()
- X {
- X int i, j, k, max_key, tc_def, more_keys;
- X
- X if (!(hp = fopen("bsd.h", "w")))
- X {
- X fprintf(stdout, "Can't open bsd.h\n");
- X exit(1);
- X }
- X if (!(cp = fopen("getcaps.c", "w")))
- X {
- X fprintf(stdout, "Can't open getcaps.c\n");
- X exit(1);
- X }
- X
- X fprintf(hp, "/* termcap to terminfo conversion */\n\n");
- X fprintf(hp, "#ifdef MAIN\n#define EXTERN\n");
- X fprintf(hp, "#else\n#define EXTERN extern\n#endif\n\n");
- X fprintf(hp, "typedef char *CHARSTAR;\n");
- X
- X fprintf(cp, "/* termcap to terminfo conversion */\n");
- X fprintf(cp, "#ifdef TESTCAP\n");
- X fprintf(cp, "#include \"bsd.h\"\n");
- X fprintf(cp, "#ifdef LIBTC\n");
- X fprintf(cp, "#define tgetent tcgetent\n");
- X fprintf(cp, "#define tgetnum tcgetnum\n");
- X fprintf(cp, "#define tgetflag tcgetflag\n");
- X fprintf(cp, "#define tgetstr tcgetstr\n");
- X fprintf(cp, "char ttytype[256];\n");
- X fprintf(cp, "static char *s, *t;\n");
- X fprintf(cp, "extern char *gtname();\n");
- X fprintf(cp, "static int l;\n");
- X fprintf(cp, "#endif\n");
- X fprintf(cp, "extern char *tgetstr();\n");
- X fprintf(cp, "char cap_entry[4096];\n");
- X fprintf(cp, "static char buf[4096];\n");
- X fprintf(cp, "static char *bb = buf;\n");
- X fprintf(cp, "char *captrans[] = {");
- X cpl = 1024;
- X for (i = 0; boolfnames[i]; ++i)
- X send_names(boolnames[i], boolcodes[i]);
- X for (i = 0; numfnames[i]; ++i)
- X send_names(numnames[i], numcodes[i]);
- X for (i = 0; strfnames[i]; ++i)
- X send_names(strnames[i], strcodes[i]);
- X fprintf(cp, " 0};\n");
- X fprintf(cp, "readcaps() {\n\n");
- X fprintf(cp, " tgetent(cap_entry, getenv(\"TERM\"));\n");
- X fprintf(cp, "#ifdef LIBTC\n");
- X fprintf(cp, " for (s = cap_entry; *s != '|'; s++)\n");
- X fprintf(cp, " if (*s == '\\0' | *s == ':') { s = cap_entry; break; }\n");
- X fprintf(cp, " if (*s == '|') s++;\n");
- X fprintf(cp, " for (t = ttytype; *t = *s; t++, s++)\n");
- X fprintf(cp, " if (*t == ':') { *t = '\\0'; break; }\n");
- X fprintf(cp, "#endif\n");
- X fprintf(hp, "\nEXTERN char\n"); wc = 0;
- X for (i = 0; boolfnames[i]; ++i) {
- X send(boolfnames[i]);
- X fprintf(cp, " %s = tgetflag(\"%s\");\n",
- X boolfnames[i], boolcodes[i]);
- X }
- X send("physical_tabs"); /* no terminfo equivalent */
- X fprintf(cp, " physical_tabs = tgetflag(\"pt\");\n");
- X fprintf(hp, ";\n\nEXTERN int\n"); wc = 0;
- X for (i = 0; numfnames[i]; ++i) {
- X send(numfnames[i]);
- X if (strcmp(numcodes[i], "it"))
- X {
- X fprintf(cp, " %s = tgetnum(\"%s\");\n",
- X numfnames[i], numcodes[i]);
- X }
- X else
- X {
- X fprintf(cp, "#ifndef TC\n");
- X fprintf(cp, " %s = tgetnum(\"%s\");\n",
- X numfnames[i], numcodes[i]);
- X fprintf(cp, "#endif\n");
- X }
- X }
- X fprintf(hp, ";\n\nEXTERN CHARSTAR\n"); wc = 0;
- X fprintf(cp, "#ifdef TC\n");
- X for (i = 0; i < 140; ++i) {
- X j = i / 10; k = '0' + i % 10;
- X fprintf(cp,
- X " enter_lab(\"%c%c\", tgetstr(\"%c%c\", &bb), \"%c%c\", tgetstr(\"%c%c\", &bb));\n",
- X 'm' + j, k, 'm' + j, k, 'M' + j, k, 'M' + j, k);
- X }
- X for (i = 0; tc_key[i]; i += 4) {
- X fprintf(cp,
- X " enter_lab(\"%c%c\", tgetstr(\"%c%c\", &bb), \"%c%c\", tgetstr(\"%c%c\", &bb));\n",
- X tc_key[i], tc_key[i + 1], tc_key[i], tc_key[i + 1],
- X tc_key[i + 2], tc_key[i + 3],
- X tc_key[i + 2], tc_key[i + 3]);
- X }
- X fprintf(cp, "#endif\n");
- X max_key = tc_def = 0;
- X more_keys = 1;
- X for (i = 0; strfnames[i]; ++i) {
- X send(strfnames[i]);
- X k = strcodes[i][0];
- X j = strcodes[i][1];
- X if (k == 'k' && ((j >= '0' && j <= '9') || j == ';'))
- X {
- X if (tc_def) { fprintf(cp, "#endif\n"); tc_def = 0; }
- X max_key = i;
- X k = (j == ';') ? 10 : j - '0';
- X fprintf(cp,
- X " enter_lab(\"k%c\", key_f%d = tgetstr(\"k%c\", &bb),\n\t\t\"l%c\", lab_f%d = tgetstr(\"l%c\", &bb));\n",
- X j, k, j, j, k, j);
- X }
- X else
- X if (more_keys && (strnames[i][0] == 'k' ||
- X (k == 't' && j == 'a')))
- X {
- X if (tc_def) { fprintf(cp, "#endif\n"); tc_def = 0; }
- X max_key = i;
- X fprintf(cp,
- X " enter_key(\"%s\", %s = tgetstr(\"%s\", &bb));\n",
- X strcodes[i], strfnames[i], strcodes[i]);
- X if (strcmp("tab", strfnames[i]) == 0) more_keys = 0;
- X }
- X else
- X {
- X /* watch out for TC function keys */
- X if ((k >= 'm' & k <= 'z') && (j >= '0' & j <= '9'))
- X {
- X if (!tc_def) fprintf(cp, "#ifndef TC\n");
- X tc_def = 1;
- X }
- X else
- X if (tc_def)
- X {
- X fprintf(cp, "#endif\n");
- X tc_def = 0;
- X }
- X fprintf(cp, " %s = tgetstr(\"%s\", &bb);\n",
- X strfnames[i], strcodes[i]);
- X }
- X }
- X if (tc_def) fprintf(cp, "#endif\n");
- X send("reset_string"); /* terminfo maps it wrong */
- X fprintf(cp, " reset_string = tgetstr(\"rs\");\n");
- X fprintf(hp, ";\n");
- X remap_keys("TC", tc_remap);
- X remap_keys("XENIX", xenix_remap);
- X fprintf(hp, "\n#define MAX_STRINGS %d\n", i);
- X fprintf(cp, "}\n#endif\n");
- X fprintf(cp, "#ifndef SVR3\n");
- X fprintf(cp, "#ifndef SVR3_2\n");
- X fprintf(cp, "char *strnames[] = {\n\t");
- X j = 8;
- X for (i = 0; i < max_key; ++i) {
- X j += strlen(strnames[i]) + 4;
- X fprintf(cp, "\"%s\"", strnames[i]);
- X if (j > 65)
- X {
- X fprintf(cp, ",\n ");
- X j = 8;
- X }
- X else fprintf(cp, ", ");
- X }
- X fprintf(cp, "0};\n#endif\n");
- X fprintf(cp, "#endif\n");
- X fclose(cp);
- X fclose(hp);
- X }
- END_OF_FILE
- if test 12849 -ne `wc -c <'build.c'`; then
- echo shar: \"'build.c'\" unpacked with wrong size!
- fi
- # end of 'build.c'
- fi
- if test -f 'control.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'control.c'\"
- else
- echo shar: Extracting \"'control.c'\" \(37322 characters\)
- sed "s/^X//" >'control.c' <<'END_OF_FILE'
- X/*
- X** This software is Copyright (c) 1991 by Daniel Weaver.
- X**
- X** Permission is hereby granted to copy, distribute or otherwise
- X** use any part of this package as long as you do not try to make
- X** money from it or pretend that you wrote it. This copyright
- X** notice must be maintained in any copy made.
- X**
- X** Use of this software constitutes acceptance for use in an AS IS
- X** condition. There are NO warranties with regard to this software.
- X** In no event shall the author be liable for any damages whatsoever
- X** arising out of or in connection with the use or performance of this
- X** software. Any use of this software is at the user's own risk.
- X**
- X** If you make modifications to this software that you feel
- X** increases it usefulness for the rest of the community, please
- X** email the changes, enhancements, bug fixes as well as any and
- X** all ideas to me. This software is going to be maintained and
- X** enhanced as deemed necessary by the community.
- X*/
- X/* terminfo test program control subroutines */
- X
- X#include "curses.h"
- X#include "ted.h"
- X
- Xextern char * malloc();
- Xextern char letters[];
- X/* CPMS_SHIFT defines the effective range for tty_cpms.
- X Low numbers are more accurate at high baud rates and high numbers
- X must be used for low baud rates. The number should be in the
- X range of 7 to 11.
- X*/
- X#define CPMS_SHIFT 11
- X#define BUMP_CPMS (1 << (CPMS_SHIFT - 1))
- Xstatic int tty_cpms; /* characters per micro second shifted left CPMS_SHIFT */
- X
- X#ifdef ACCO
- Xextern FILE *fpacco;
- X#endif
- X
- Xstatic void
- Xrate_status(tps, test_type, results)
- Xchar *tps, *test_type, *results;
- X { /* display the results of the baud rate test */
- X int j;
- X
- X if (has_status_line)
- X {
- X putp(tparm(to_status_line, 0));
- X ptext(test_type);
- X putchp(' ');
- X ptext(results);
- X j = columns - strlen(results) - strlen(test_type) - 2;
- X /* pad the line with blanks */
- X for ( ; --j > 0; ) putchp(' ');
- X putp(from_status_line);
- X home_down();
- X ptext(tps);
- X j = strlen(tps);
- X }
- X else
- X {
- X home_down();
- X ptext(tps);
- X putchp(' ');
- X ptext(results);
- X j = strlen(tps) + strlen(results) + 1;
- X }
- X /* pad the line with blanks */
- X for ( ; ++j < columns; ) putchp(' ');
- X }
- X
- X
- Xvoid
- Xfind_baud_rate()
- X{ /* calculate the baud rate from the number of characters sent */
- X int j, k, l, sync, upper, test_number;
- X long max_time, test_time;
- X char cur_num[16];
- X static char *test_item[] = {
- X "character", "line feed", "clear"};
- X long max_rate[3];
- X char text_rate[3][16], xxx_per_sec[3][64], summary[3][80];
- X
- X upper = test_number = reps = 0;
- X max_rate[0] = max_rate[1] = max_rate[2] = 0;
- X letter = letters[letter_number = 0];
- X max_time = 20;
- X rate_status("begin baud rate search. ", test_item[test_number], "");
- X for (l = 0; l < 3; l++) {
- X xxx_per_sec[l][0] = summary[l][0] = '\0';
- X }
- X for (l = 1; ; ++l) {
- X (void) tty_sync_error();
- X char_sent = ops = 0;
- X start_time = end_time = time(0);
- X for (sync = 0; start_time + max_time >= end_time; ) {
- X ++sync;
- X switch (test_number) {
- X case 0: /* full screen */
- X go_home();
- X for (j = 1; j < lines; j++) {
- X for (k = 0; k < columns; k++)
- X if (k & 0xF) putchp(letter);
- X else putchp('.');
- X }
- X ops = char_sent;
- X NEXT_LETTER;
- X break;
- X case 1: /* scroll */
- X sprintf(temp, "%d", sync);
- X ptextln(temp);
- X for (j = 0; j < reps; j++) {
- X put_ind();
- X }
- X ops += reps;
- X break;
- X case 2: /* clear */
- X sprintf(temp, "%d", sync);
- X ptext(temp);
- X for (j = 0; j < reps; j++) {
- X put_clear();
- X }
- X ops += reps;
- X break;
- X }
- X if (sync >= upper)
- X {
- X if (tty_sync_error())
- X {
- X time_pad = FALSE;
- X return;
- X }
- X end_time = time(0);
- X if (start_time + max_time <= end_time) break;
- X }
- X }
- X test_time = end_time - start_time;
- X j = (ops * 10) / test_time;
- X three_digit(cur_num, j);
- X sprintf(xxx_per_sec[test_number], "%s %ss per second.",
- X cur_num, test_item[test_number]);
- X if (test_number == 0)
- X {
- X tty_baud_rate = j =
- X ((char_sent >> 1) * tty_frame_size) / test_time;
- X three_digit(cur_num, j * 10);
- X }
- X if (j > max_rate[test_number])
- X {
- X max_rate[test_number] = j;
- X strcpy(text_rate[test_number], cur_num);
- X }
- X sprintf(summary[test_number],
- X "test %d: %d sec. Cur: %s Max: %s",
- X l, end_time - start_time,
- X cur_num, text_rate[test_number]);
- X rate_status(xxx_per_sec[test_number], test_item[test_number],
- X summary[test_number]);
- X if (sync > upper)
- X {
- X if (upper == 0 && reps != 0 && sync > test_time)
- X { /* this should help it converge */
- X reps = ops / test_time;
- X sync = test_time + 1;
- X }
- X upper = sync;
- X continue;
- X }
- X j = wait_here();
- X if (j == 'r' | j == 'R') ;
- X else
- X if (j == '>')
- X {
- X upper *= 2;
- X max_time *= 2;
- X }
- X else
- X if (j == '<')
- X {
- X upper = (upper + 1) / 2;
- X max_time /= 2;
- X }
- X else
- X if (j >= '0' & j <= '2')
- X {
- X j -= '0';
- X if (j != test_number)
- X {
- X upper = 0;
- X switch (j) {
- X case 0: reps = 0; break;
- X case 1:
- X if (max_rate[j])
- X {
- X reps = max_rate[j] / 10;
- X upper = max_time;
- X }
- X else reps = 100;
- X break;
- X case 2:
- X if (max_rate[j])
- X {
- X reps = max_rate[j] / 10;
- X upper = max_time;
- X }
- X else reps = 10;
- X break;
- X }
- X }
- X test_number = j;
- X if (test_number != 0 && xon_xoff == 0)
- X {
- X ptext("\nWarning: Terminal not set for XON/XOFF.");
- X (void) wait_here();
- X }
- X }
- X else break;
- X if (test_number == 0) rate_status(xxx_per_sec[test_number],
- X test_item[test_number], summary[test_number]);
- X }
- X tty_baud_rate = max_rate[0];
- X if (has_status_line) putp(dis_status_line);
- X put_clear();
- X for (l = 0; l < 3; l++) {
- X if (xxx_per_sec[l][0])
- X {
- X ptext(xxx_per_sec[l]);
- X putchp(' ');
- X ptextln(summary[l]);
- X }
- X }
- X }
- X
- X
- Xvoid
- Xverify_time()
- X { /* verify that the time tests are ready to run */
- X int i, j;
- X long read_time;
- X
- X if (stop_testing) return;
- X maybe_wait(6);
- X fflush(stdout);
- X sleep(1);
- X if (stty_query(TTY_CHAR_MODE))
- X put_str("Hit lower case g to start testing...");
- X else put_str("Hit lower case g and CR to start testing...");
- X i = tty_sync_error();
- X if (i == FALSE) i = getchp(STRIP_PARITY);
- X if (i != 'g')
- X {
- X /* Either the terminal did not respond or the user
- X does not like us. If the terminal returned nothing
- X then (i & 255) will equal 'g'. If the terminal
- X returned too many characters then we should scan
- X the input for the 'g'. If the user refuses to type
- X a 'g' then try to cut him a break. */
- X tty_can_sync = FALSE;
- X ptext("\nThis program expects the ENQ sequence to be");
- X ptext(" answered with the ACK character. This will help");
- X ptext(" the program reestablish synchronization when");
- X ptextln(" the terminal is overrun with data.");
- X ptext("\nENQ sequence: "); putln(expand(tty_ENQ));
- X ptext("ACK recieved: "); putln(expand(tty_ACK));
- X sprintf(temp, "Length of ACK %d. Expected length of ACK %d.",
- X strlen(tty_ACK), junk_chars + 1);
- X ptextln(temp);
- X temp[0] = ACK_char; temp[1] = '\0';
- X ptext("Terminating character: "); putln(expand(temp));
- X j = wait_here();
- X if (!stty_query(TTY_CHAR_MODE) || (i & 255) == 'g') return;
- X read_time = time(0);
- X for (i = 1; i < 20 && j != 'g'; i++) {
- X j = wait_here();
- X if (time(0) - read_time > 2) break;
- X }
- X return;
- X }
- X tty_can_sync = 2;
- X if (tty_baud_rate == 0)
- X {
- X find_baud_rate();
- X if (tty_baud_rate == 0)
- X {
- X ptextln("unable to determine baud rate.");
- X (void) wait_here();
- X }
- X }
- X }
- X
- X
- Xvoid
- Xcontrol_init()
- X { /* called when baud rate or test length changes */
- X if (test_length <= 0) test_length = 1;
- X full_test = ((tty_baud_rate * test_length) / tty_frame_size) << 1;
- X char_max = full_test;
- X /* the following equation should read...
- X (tty_baud_rate << CPMS_SHIFT) + (tty_frame_size / 2) * 5000)
- X tty_cpms = -----------------------------------------------------------
- X (tty_frame_size / 2) * 10000
- X but I rewrote it to work with integer arithmetic
- X */
- X tty_cpms = ((tty_baud_rate << (CPMS_SHIFT - 2)) + tty_frame_size * 625)
- X / (tty_frame_size * 1250);
- X rated_lines = (lines * tty_baud_rate) / 9600;
- X if (rated_lines < 3) rated_lines = 3;
- X else
- X if (rated_lines > lines) rated_lines = lines;
- X }
- X
- X
- X#ifdef TESTCAP
- Xint
- Xcap_index(c, l)
- Xchar *c;
- Xint l;
- X { /* find the terminfo name in the captrans[] array */
- X int i;
- X
- X for (i = 0; captrans[i]; i++) {
- X if (!strncmp(c, captrans[i], l))
- X if (captrans[i][l] == ':') return i;
- X }
- X return -1;
- X }
- X
- X
- Xchar *
- Xcap_to_info(c)
- Xchar *c;
- X { /* translate the termcap name to a terminfo name */
- X int i, j;
- X static char tinfo[16];
- X
- X for (i = 0; captrans[i]; i++) {
- X for (j = 0; captrans[i][j]; ) {
- X if (captrans[i][j++] == ':') break;
- X }
- X if (!strcmp(c, &captrans[i][j])) {
- X strncpy(tinfo, captrans[i], j - 1);
- X return tinfo;
- X }
- X }
- X return (char *) 0;
- X }
- X
- X
- Xvoid
- Xpad_time(cap, star, plain)
- Xchar *cap;
- Xint *star, *plain;
- X { /* return the pad time in tens of miliseconds */
- X int val, dec;
- X
- X *star = *plain = 0;
- X if (!cap) return;
- X for (val = dec = 0; *cap; ++cap) {
- X if (*cap >= '0' & *cap <= '9') val = val * 10 + *cap - '0';
- X else
- X if (*cap == '.') dec = 1;
- X else break;
- X }
- X if (!dec) val *= 10;
- X if (*cap == '*') *star = val;
- X else *plain = val;
- X }
- X
- X
- Xchar *
- Xliberated(cap)
- Xchar *cap;
- X { /* return the cap without the padding */
- X if (cap)
- X for ( ; *cap; ++cap) {
- X if (*cap != '.' && *cap != '*' &&
- X (*cap < '0' | *cap > '9')) break;
- X }
- X return cap;
- X }
- X
- X#else /* terminfo */
- X
- Xvoid
- Xpad_time(cap, star, plain)
- Xchar *cap;
- Xint *star, *plain;
- X { /* return the pad time in tens of miliseconds */
- X int dec, i;
- X
- X *star = *plain = 0;
- X if (!cap) return;
- X for ( ; *cap; ++cap) {
- X if (*cap == '$' & cap[1] == '<')
- X {
- X cap += 2;
- X for (i = dec = 0; ; ++cap) {
- X if (!*cap) return;
- X if (*cap >= '0' & *cap <= '9')
- X i = i * 10 + *cap - '0';
- X else
- X if (*cap == '.') dec = 1;
- X else
- X if (*cap == '*')
- X {
- X if (!dec) i *= 10;
- X *star += i;
- X i = 0;
- X }
- X else
- X if (*cap == '>')
- X {
- X if (!dec) i *= 10;
- X *plain += i;
- X break;
- X }
- X else
- X if (*cap != '/') break;
- X }
- X }
- X
- X }
- X }
- X
- X
- Xchar *
- Xliberated(cap)
- Xchar *cap;
- X { /* return the cap without the padding */
- X static char cb[512];
- X char *ts, *ls;
- X
- X cb[0] = '\0'; ls = NULL;
- X if (cap)
- X for (ts = cb; *ts = *cap; ++cap) {
- X if (*cap == '$' && cap[1] == '<') ls = ts;
- X ++ts;
- X if (*cap == '>')
- X if (ls)
- X {
- X ts = ls; ls = NULL;
- X }
- X }
- X return cb;
- X }
- X#endif
- X
- X
- Xint
- Xenter_cap(n, v)
- Xchar *n, *v;
- X { /* enter a cap into the cap_list (for time tests) */
- X int i;
- X
- X /* find an empty slot */
- X for (i = 0; cap_list[i].value; ++i) {
- X if (i >= CAP_MAX) return -1;
- X if (!strcmp(cap_list[i].value, v))
- X {
- X if (cap_list[i].name && n &&
- X strcmp(cap_list[i].name, n)) continue;
- X if (!cap_list[i].name) cap_list[i].name = n;
- X return i;
- X }
- X }
- X cap_list[i].value = v;
- X cap_list[i].name = n;
- X cap_list[i].new_star = cap_list[i].new_plain = 32767;
- X pad_time(v, &cap_list[i].cur_star, &cap_list[i].cur_plain);
- X return i;
- X }
- X
- X
- Xvoid
- Xprint_cap_list()
- X { /* print the cap list created by enter_cap() */
- X int i, j, l;
- X char b1[16], b2[16], b3[16], fn[128], *s;
- X FILE *fp;
- X
- X sprintf(temp, "Write summary of pad times to ted.%s. Hit 'x' to abort.", tty_shortname);
- X ptext(temp);
- X i = wait_here();
- X if (i == 'x' | i == 'X') return;
- X
- X sprintf(fn, "ted.%s", tty_shortname);
- X if (!(fp = fopen(fn, "w"))) return;
- X
- X for (i = 0; cap_list[i].value; ++i) {
- X if (cap_list[i].cur_star == 0) b1[0] = '\0';
- X else sprintf(b1, "%3d.%d*",
- X cap_list[i].cur_star / 10,
- X cap_list[i].cur_star % 10);
- X if (cap_list[i].new_plain == 32767) b2[0] = '\0';
- X else sprintf(b2, "%3d.%d",
- X cap_list[i].new_plain / 10,
- X cap_list[i].new_plain % 10);
- X if (cap_list[i].new_star == 32767) b3[0] = '\0';
- X else sprintf(b3, "%3d.%d*",
- X cap_list[i].new_star / 10,
- X cap_list[i].new_star % 10);
- X if (cap_list[i].name)
- X {
- X s = cap_list[i].name;
- X#ifdef TESTCAP
- X l = strlen(s);
- X j = cap_index(s, l);
- X if (j >= 0) s = &captrans[j][l + 1];
- X#endif
- X }
- X else s = "";
- X sprintf(temp, "%-5s %3d.%d %6s %5s %6s %s", s,
- X cap_list[i].cur_plain / 10,
- X cap_list[i].cur_plain % 10,
- X b1, b2, b3, print_expand(cap_list[i].value));
- X fprintf(fp, "%s\n", temp);
- X }
- X fclose(fp);
- X }
- X
- X
- Xint
- Xbegin_pad_char(clr)
- Xint clr;
- X { /* handle beginning of test response character */
- X int ch;
- X
- X while (1) {
- X ch = wait_here();
- X if (ch == 'q' || ch == 'Q')
- X {
- X ptext("Enter Y to quit:");
- X ch = wait_here();
- X if (ch == 'y' || ch == 'Y')
- X {
- X stop_testing = TRUE;
- X return FALSE;
- X }
- X }
- X else
- X if (ch == 'c' || ch == 'C')
- X {
- X put_clear();
- X continue;
- X }
- X else
- X if (ch == '>') test_length *= 2;
- X else
- X if (ch == '<') test_length /= 2;
- X else
- X {
- X if (clr) put_clear();
- X char_count = 0;
- X start_time = time(0);
- X return (ch != 'n' && ch != 'N');
- X }
- X control_init();
- X sprintf(temp, "\nPad test will run %d seconds.",
- X test_length);
- X ptext(temp);
- X }
- X }
- X
- X
- Xvoid
- Xkotex()
- X { /* change the pads for the current test */
- X int i, v, ch, star, slash, change, dot;
- X char *value;
- X
- X put_clear();
- X for (i = 0; i < EDIT_MAX; i++) {
- X if (ced_name[i] && ced_value[i])
- X {
- X sprintf(temp, "(%s) %s", ced_name[i], expand(*ced_value[i]));
- X ptextln(temp);
- X }
- X }
- X if (line_count == 0)
- X {
- X ptext("No valid entry for edit.");
- X (void) wait_here();
- X return;
- X }
- X ptextln("Enter new pads. 0 for no pad. CR for no change.");
- X for (i = 0; i < EDIT_MAX; i++) {
- X if (ced_name[i] && ced_value[i])
- X {
- X sprintf(temp, "\n(%s) ", ced_name[i]);
- X ptext(temp);
- X star = slash = change = FALSE;
- X dot = 0;
- X for (v = 0; ch = getchp(STRIP_PARITY); ) {
- X if (ch >= '0' & ch <= '9')
- X {
- X v = ch - '0' + v * 10;
- X if (dot) dot++;
- X }
- X else
- X if (ch == '*') star = TRUE;
- X#ifndef TESTCAP
- X else
- X if (ch == '/') slash = TRUE;
- X else
- X if (ch == '.') dot = 1;
- X#endif
- X else break;
- X change = TRUE;
- X if (stty_query(TTY_NOECHO)) putch(ch);
- X }
- X if (!change) continue;
- X while (dot > 2) {
- X v /= 10;
- X dot--;
- X }
- X if (v == 0) strcpy(temp, liberated(*ced_value[i]));
- X else
- X#ifdef TESTCAP
- X sprintf(temp, "%d%s%s", v, star ? "*" : "",
- X liberated(*ced_value[i]));
- X#else
- X if (dot == 2)
- X sprintf(temp, "%s$<%d.%d%s%s>",
- X liberated(*ced_value[i]), v / 10,
- X v % 10, star ? "*" : "", slash ? "/" : "");
- X else
- X sprintf(temp, "%s$<%d%s%s>",
- X liberated(*ced_value[i]),
- X v, star ? "*" : "", slash ? "/" : "");
- X#endif
- X if (value = malloc(strlen(temp) + 1))
- X strcpy(value, temp);
- X strcpy(temp, liberated(*ced_value[i]));
- X *ced_value[i] = value;
- X
- X if (temp[0] == '\0')
- X#ifdef TESTCAP
- X value = "";
- X#else
- X value = "$<>";
- X#endif
- X else
- X {
- X if (value = malloc(strlen(temp) + 1))
- X strcpy(value, temp);
- X }
- X ch = enter_cap(ced_name[i], value);
- X if (dot != 2) v *= 10;
- X if (star) cap_list[ch].new_star = v;
- X else cap_list[ch].new_plain = v;
- X write_ted_file = TRUE;
- X }
- X }
- X }
- X
- X
- Xint
- Xend_pad_char(clr)
- Xint clr;
- X { /* process the character(s) at the end of a test */
- X /* return FALSE if end of loop */
- X int ch;
- X static char *help[] = {
- X "c - continue",
- X "d - double the number of lines (or characters)",
- X "h - cut number of lines (or characters) in half",
- X "i - send the reset and init strings",
- X "p - change the padding for this capibility",
- X "q - quit (prompts for verification)",
- X "r - rerun test",
- X "n - go on to next test",
- X "? - print this help message",
- X "< - decrease the time for each test",
- X "> - increase the time for each test",
- X "<number> - change the number of lines (or characters)",
- X 0};
- X
- X ch = wait_here();
- X set_attr(0); /* just in case */
- X for ( ; ; ) {
- X switch (ch) {
- X case '?':
- X for (ch = 0; help[ch]; ch++) {
- X ptextln(help[ch]);
- X }
- X sprintf(temp, "Tests will affect %d lines (or characters).",
- X augment);
- X ptextln(temp);
- X sprintf(temp, "Tests will run %d seconds.", test_length);
- X ptextln(temp);
- X if (debug_level > 0)
- X {
- X sprintf(temp, "cpms = %f %d, pad_sent=%d, milli_pad=%d ",
- X (float)tty_cpms / (float)(1 << CPMS_SHIFT), tty_cpms,
- X pad_sent, milli_pad);
- X ptextln(temp);
- X sprintf(temp, "OUTPUT TRANS %d, NOECHO %d, CHAR MODE %d",
- X stty_query(TTY_OUT_TRANS) != 0,
- X stty_query(TTY_NOECHO) != 0,
- X stty_query(TTY_CHAR_MODE) != 0);
- X ptextln(temp);
- X }
- X
- X /* in case the "Done" gets eaten */
- X ptext(done_test);
- X break;
- X case '>':
- X case '<':
- X if (ch == '>') test_length *= 2;
- X else test_length /= 2;
- X control_init();
- X sprintf(temp, "\nPad test will run %d seconds.",
- X test_length);
- X ptext(temp);
- X break;
- X case 'C':
- X put_clear();
- X case 'c':
- X /* continue */
- X break;
- X case 'd':
- X case 'D':
- X /* double the test augment */
- X augment *= 2;
- X sprintf(temp, "\nPad test will affect %d lines (or characters).",
- X augment);
- X ptext(temp);
- X break;
- X case 'h':
- X case 'H':
- X /* cut the test augment in half */
- X augment /= 2;
- X sprintf(temp, "\nPad test will affect %d lines (or characters).",
- X augment);
- X ptext(temp);
- X break;
- X case 'i':
- X case 'I':
- X /* send the reset and init strings */
- X reset_init(TRUE);
- X putp(exit_insert_mode);
- X replace_mode = 1;
- X put_mode(exit_attribute_mode);
- X break;
- X case '0': case '1': case '2': case '3': case '4':
- X case '5': case '6': case '7': case '8': case '9':
- X /* read a new test augment */
- X augment = 0;
- X while(ch >= '0' & ch <= '9')
- X {
- X if (stty_query(TTY_NOECHO)) putch(ch);
- X augment = ch - '0' + augment * 10;
- X ch = getchp(STRIP_PARITY);
- X }
- X sprintf(temp, "\nPad test will affect %d lines (or characters).",
- X augment);
- X ptext(temp);
- X break;
- X case 'p':
- X case 'P':
- X kotex();
- X break;
- X case 'q':
- X case 'Q':
- X ptext("Enter Y to quit:");
- X ch = wait_here();
- X if (ch == 'y' || ch == 'Y')
- X {
- X stop_testing = TRUE;
- X return FALSE;
- X }
- X break;
- X case 'r':
- X case 'R':
- X if (augment < 1) augment = 1;
- X char_max = full_test;
- X put_clear();
- X char_sent = 0;
- X if (time_pad) return enq_ack();
- X start_time = time(0);
- X return TRUE;
- X case 'n':
- X case 'N':
- X skip_next = TRUE;
- X default:
- X if (clr) put_clear();
- X return FALSE;
- X }
- X ptext("\nHit (c,d,h,i,n,p,q,r,<,>,?,<number>,CR) ");
- X ch = wait_here();
- X }
- X }
- X
- X
- Xint
- Xrun_test(cap, msg, acknowledge)
- Xchar *cap, *msg;
- Xint acknowledge;
- X { /* used to begin execution of a string capibility test */
- X char *s;
- X
- X if (msg)
- X {
- X /* look the for first cap */
- X for (s = msg; *s && *s != '('; s++);
- X can_test(s);
- X }
- X if (stop_testing) return FALSE;
- X if (cap) return TRUE;
- X if (msg)
- X {
- X ptextln(msg);
- X if (acknowledge) (void) wait_here();
- X }
- X return FALSE;
- X }
- X
- X
- Xint
- Xrun_mode(caps)
- Xchar *caps;
- X { /* used to begin execution of a boolean or numeric capibility */
- X can_test(caps);
- X if (stop_testing) return FALSE;
- X return TRUE;
- X }
- X
- X
- Xint
- Xrepeat_test(clr)
- Xint clr;
- X { /* used to end a test */
- X int ch;
- X
- X if (stop_testing) return FALSE;
- X for ( ; ; ) {
- X switch (ch = wait_here()) {
- X case 'C':
- X put_clear();
- X case 'c':
- X /* continue */
- X break;
- X case 'i':
- X case 'I':
- X /* send the reset and init strings */
- X reset_init(TRUE);
- X putp(exit_insert_mode);
- X replace_mode = 1;
- X put_mode(exit_attribute_mode);
- X break;
- X case 'q':
- X case 'Q':
- X ptext("Enter Y to quit:");
- X ch = wait_here();
- X if (ch == 'y' || ch == 'Y')
- X {
- X stop_testing = TRUE;
- X return FALSE;
- X }
- X break;
- X case 'r':
- X case 'R':
- X put_clear();
- X return TRUE;
- X case 'n':
- X case 'N':
- X skip_next = TRUE;
- X default:
- X if (clr) put_clear();
- X return FALSE;
- X }
- X ptext("\nHit (c,i,n,q,r,CR) ");
- X }
- X }
- X
- X
- Xvoid
- Xshort_subject(r)
- Xint r;
- X { /* set the value of pad_sent */
- X /* acco_pad() accumulates the pad counts in milli_reps and
- X milli_pad, then short_subject() converts them to characters and
- X stores the result in pad_sent. Note: milli_pad and milli_rep
- X are in tenths of a milli-second. */
- X
- X pad_sent = 0;
- X if (xon_xoff | no_pad_char) pad_sent = ((milli_pad + milli_reps * r)
- X * tty_cpms + BUMP_CPMS) >> CPMS_SHIFT;
- X }
- X
- X
- Xint
- Xacco_pad(name, cap)
- Xchar *name, *cap;
- X{ /* ajust the length of the pad test if the user has XON/XOFF set */
- X int p;
- X
- X if ((p = enter_cap(name, cap)) != -1)
- X {
- X milli_reps += cap_list[p].cur_star;
- X milli_pad += cap_list[p].cur_plain;
- X }
- X short_subject(1);
- X return TRUE;
- X}
- X
- X
- Xint
- Xbegin_test(cap, name, long_name, alt, clr)
- Xchar **cap, *name, *long_name, *alt;
- Xint clr;
- X { /* clear the screen and start the test (special case) */
- X int ch;
- X
- X can_test(name); can_test(alt);
- X if (stop_testing) return FALSE;
- X if (cap_select && strcmp(cap_select, name))
- X if (!alt || (strcmp(cap_select, alt) != 0)) return FALSE;
- X if (resume_testing) cap_select = NULL;
- X if (*cap)
- X {
- X for (ch = 0; ch < EDIT_MAX; ced_name[ch++] = NULL);
- X ced_value[0] = cap;
- X ced_name[0] = name;
- X letter = letters[letter_number = 0];
- X put_clear();
- X clear_select = -1;
- X char_max = full_test;
- X rerun = FALSE;
- X reps = ops = test_count = milli_pad = milli_reps = 0;
- X sprintf(done_test, "Done. (%s)", current_test = name);
- X capper = enter_cap(current_test, *cap);
- X (void) acco_pad(name, *cap);
- X if (time_pad) return enq_ack();
- X sprintf(temp,
- X "Begin (%s) pad test, hit CR to continue, n to skip test",
- X name);
- X ptext(temp);
- X return begin_pad_char(clr);
- X }
- X sprintf(temp, "(%s) %s, not present", name, long_name);
- X ptextln(temp);
- X if (!time_pad)
- X {
- X ch = wait_here();
- X if (ch == 'c' || ch == 'C') put_clear();
- X }
- X return FALSE;
- X }
- X
- X
- Xint
- Xmulti_test(error_name, clr, or_bits, and_bits, acco_bits, num_caps,
- X cn1, cv1, cn2, cv2, cn3, cv3, cn4, cv4)
- Xint clr, or_bits, and_bits, acco_bits, num_caps;
- Xchar *error_name;
- Xchar *cn1, *cn2, *cn3, *cn4;
- Xchar **cv1, **cv2, **cv3, **cv4;
- X { /* clear the screen and start the test (general case) */
- X int ch, i, or_flag, and_flag, select_flag;
- X static char name_buffer[128];
- X
- X ced_name[0] = cn1; ced_name[1] = cn2;
- X ced_name[2] = cn3; ced_name[3] = cn4;
- X ced_value[0] = cv1; ced_value[1] = cv2;
- X ced_value[2] = cv3; ced_value[3] = cv4;
- X for (i = 0; i < num_caps; i++) {
- X can_test(ced_name[i]);
- X }
- X if (stop_testing) return FALSE;
- X test_count = milli_pad = milli_reps = 0;
- X or_flag = or_bits & 1;
- X and_flag = and_bits & 1;
- X select_flag = !cap_select;
- X name_buffer[0] = '\0';
- X ch = 0;
- X#ifdef ACCO
- X fprintf(fpacco, "(");
- X if (or_flag)
- X fprintf(fpacco, "TRUE");
- X else
- X for (i = 0; i < num_caps; i++) {
- X if ((or_bits >> i) & 2)
- X {
- X fprintf(fpacco, "%s", ced_name[i]);
- X if ((or_bits >> i) & -4) fprintf(fpacco, "|");
- X }
- X }
- X fprintf(fpacco, ")|(");
- X if (and_flag)
- X for (i = 0; i < num_caps; i++) {
- X if ((and_bits >> i) & 2)
- X {
- X fprintf(fpacco, "%s", ced_name[i]);
- X if ((and_bits >> i) & -4) fprintf(fpacco, "&");
- X }
- X }
- X else
- X fprintf(fpacco, "FALSE");
- X fprintf(fpacco, ") ACCO(");
- X for (i = 0; i < num_caps; i++) {
- X if ((acco_bits >> i) & 2)
- X {
- X fprintf(fpacco, "%s", ced_name[i]);
- X if ((acco_bits >> i) & -4) fprintf(fpacco, "+");
- X }
- X }
- X fprintf(fpacco, ") %s\n", error_name ? error_name : "");
- X#endif
- X for (i = 0; i < num_caps; i++) {
- X if ((or_bits >> i) & 2)
- X or_flag |= *ced_value[i] != NULL;
- X if ((and_bits >> i) & 2)
- X and_flag &= *ced_value[i] != NULL;
- X if (*ced_value[i] && ((acco_bits >> i) & 2))
- X {
- X ++ch;
- X capper = enter_cap(ced_name[i], *ced_value[i]);
- X (void) acco_pad(ced_name[i], *ced_value[i]);
- X }
- X if (cap_select)
- X select_flag |= strcmp(cap_select, ced_name[i]) == 0;
- X sprintf(&name_buffer[strlen(name_buffer)], "(%s) ", ced_name[i]);
- X }
- X if (!select_flag) return FALSE;
- X if (resume_testing) cap_select = NULL;
- X if (or_flag | and_flag)
- X {
- X for (i = num_caps; i < EDIT_MAX; ced_name[i++] = NULL);
- X sprintf(done_test, "Done. %s", current_test = name_buffer);
- X letter = letters[letter_number = 0];
- X put_clear();
- X clear_select = -1;
- X char_max = full_test;
- X reps = ops = 0;
- X rerun = FALSE;
- X if (ch != 1) capper = -1;
- X if (time_pad) return enq_ack();
- X put_str("Begin "); ptext(name_buffer);
- X ptext("pad test, hit CR to continue, n to skip test");
- X return begin_pad_char(clr);
- X }
- X ptext(error_name);
- X ptextln(", not present");
- X if (!time_pad)
- X {
- X ch = wait_here();
- X if (ch == 'c' || ch == 'C') put_clear();
- X }
- X return FALSE;
- X }
- X
- X
- Xstatic int
- Xtime_test_state(clr)
- Xint clr;
- X { /* calculate and report the suggested pad times */
- X long v;
- X
- X /* time is one of the things that UNIX does poorly.
- X So I fuss around with sloppy numbers. */
- X v = end_time - start_time -
- X ((char_sent >> 1) * tty_frame_size) / tty_baud_rate;
- X if (v <= 1 && !rerun) return 0;
- X if (capper == -2)
- X { /* truely brain damaged terminals come here */
- X v = ((char_sent >> 1) * tty_frame_size)
- X / (end_time - start_time);
- X sprintf(temp, "This terminal has a maximum effective baud rate of %d. ", v);
- X ptext(temp);
- X ptext(" System load may be to high. ");
- X ptextln(" The results of this test will be incorrect!");
- X return 2;
- X }
- X else
- X {
- X if (ops) v = (v * 10000 + ops / 2) / ops;
- X if (capper == -1) put_str("combined");
- X else
- X {
- X sprintf(temp, "(%s)", cap_list[capper].name);
- X ptext(temp);
- X }
- X put_dec(" pad time should be %d.%d milliseconds", v);
- X
- X if (reps)
- X {
- X sprintf(temp, " for %d reps.", reps);
- X ptextln(temp);
- X put_dec("%d.%d* milliseconds per rep", v / reps);
- X }
- X put_crlf();
- X
- X if (capper >= 0)
- X {
- X if (milli_pad < cap_list[capper].new_plain)
- X cap_list[capper].new_plain = v;
- X if (reps != 0 &&
- X v / reps < cap_list[capper].new_star)
- X cap_list[capper].new_star = v / reps;
- X /* if the terminal makes it here once
- X then we want to report each time.
- X This forces a smaller number into
- X the tables. */
- X rerun = TRUE;
- X }
- X if (milli_reps != 0 && reps != 0)
- X {
- X ptext("current value is ");
- X if (milli_pad)
- X put_dec("%d.%d milliseconds and ",
- X milli_pad);
- X put_dec("%d.%d* milliseconds per rep",
- X milli_reps);
- X }
- X else put_dec("current value is %d.%d milliseconds", milli_pad);
- X put_crlf();
- X if (clear_select != -1)
- X {
- X clr_test_value[clear_select] = v;
- X clr_test_reps[clear_select] = reps;
- X }
- X }
- X return 0;
- X }
- X
- X
- Xint
- Xend_test(txt, clr)
- Xchar *txt;
- Xint clr;
- X { /* This code is executed at the bottom of each test to print
- X the "Done" message and control the looping of tests */
- X int sync_error;
- X
- X test_count++;
- X if (char_sent < char_max) return TRUE;
- X if (txt) ptext(txt);
- X cap_tested = 1;
- X sync_error = 0;
- X if (tty_can_sync) sync_error = tty_sync_error();
- X if (xon_xoff && sync_error == 0 && test_length >= 10)
- X {
- X end_time = time(0);
- X ptext(done_test);
- X switch (time_test_state(clr)) {
- X case 0:
- X if (time_pad) return FALSE;
- X break;
- X case 1:
- X if (time_pad) return TRUE;
- X break;
- X case 2:
- X break;
- X }
- X }
- X else ptext(done_test);
- X ops = 0;
- X return end_pad_char(clr);
- X }
- X
- X
- Xvoid
- Xpage_loop()
- X { /* send CR/LF or go home and bump letter */
- X if (line_count + 2 >= lines)
- X {
- X NEXT_LETTER;
- X go_home();
- X }
- X else put_crlf();
- X }
- END_OF_FILE
- if test 37322 -ne `wc -c <'control.c'`; then
- echo shar: \"'control.c'\" unpacked with wrong size!
- fi
- # end of 'control.c'
- fi
- if test -f 'tparam.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tparam.c'\"
- else
- echo shar: Extracting \"'tparam.c'\" \(1473 characters\)
- sed "s/^X//" >'tparam.c' <<'END_OF_FILE'
- X/*
- X** This software is Copyright (c) 1991 by Daniel Weaver.
- X**
- X** Permission is hereby granted to copy, distribute or otherwise
- X** use any part of this package as long as you do not try to make
- X** money from it or pretend that you wrote it. This copyright
- X** notice must be maintained in any copy made.
- X**
- X** Use of this software constitutes acceptance for use in an AS IS
- X** condition. There are NO warranties with regard to this software.
- X** In no event shall the author be liable for any damages whatsoever
- X** arising out of or in connection with the use or performance of this
- X** software. Any use of this software is at the user's own risk.
- X**
- X** If you make modifications to this software that you feel
- X** increases it usefulness for the rest of the community, please
- X** email the changes, enhancements, bug fixes as well as any and
- X** all ideas to me. This software is going to be maintained and
- X** enhanced as deemed necessary by the community.
- X*/
- X
- X/*
- X** This subroutine should be tparm() as written by the Free Software Foundation.
- X** But the nice folks at FSF would not let me give it away free.
- X** The version I use for my testing was lifted from emacs and I recommend
- X** that you do the same. FSF should change its name to the Free Lunch
- X** Foundation.
- X**
- X** System V users can deep 6 this file all together.
- X*/
- X#ifdef TESTCAP
- Xextern char *tgoto();
- X
- Xchar *
- Xtparm(cap, a, b)
- Xchar *cap;
- Xint a, b;
- X{
- X if (cap) return tgoto(cap, b, a);
- X return "";
- X}
- X#endif
- END_OF_FILE
- if test 1473 -ne `wc -c <'tparam.c'`; then
- echo shar: \"'tparam.c'\" unpacked with wrong size!
- fi
- # end of 'tparam.c'
- fi
- echo shar: End of archive 3 \(of 7\).
- cp /dev/null ark3isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 7 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-